/*
 * Created on 11.12.2009
 *
 * (c) Copyright Christian P. Fries, Germany. All rights reserved. Contact: email@christian-fries.de.
 */
package YahooFinance;

import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;

/**
 * @author Christian Fries
 */
public class MarketDataBean {

	String symbol;
	double price;
	double change;
	double volume;
	Date date;
	long lastUpdate;

	public String getDateAsString() {
		DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
		df.setTimeZone(TimeZone.getTimeZone("Europe/Berlin"));
		String strDate = df.format(date);
		return strDate + (" (CET)");
	}

	public String getTimeAsString() {
		DateFormat df = new SimpleDateFormat("HH:mm");
		df.setTimeZone(TimeZone.getTimeZone("Europe/Berlin"));
		Calendar cal = Calendar.getInstance();
		cal.setTime(date); // sets calendar time/date
		cal.add(Calendar.HOUR_OF_DAY, -6); // adds one hour
		date = cal.getTime();
		String strDate = df.format(date);
		return strDate;
	}

	public String getPriceAsString() {
		DecimalFormat df = new DecimalFormat("####.0000");
		String strPrice = df.format(price);
		return strPrice;
	}

	public String getSymbol() {
		return symbol;
	}

	public void setSymbol(String symbol) {
		this.symbol = symbol;
	}

	public double getPrice() {
		return price;
	}

	public void setPrice(double price) {
		this.price = price;
	}

	public double getChange() {
		return change;
	}

	public void setChange(double change) {
		this.change = change;
	}

	/**
	 * @return the volume
	 */
	public double getVolume() {
		return volume;
	}

	/**
	 * @param volume
	 *            the volume to set
	 */
	public void setVolume(double volume) {
		this.volume = volume;
	}

	public long getLastUpdated() {
		return lastUpdate;
	}

	public void setLastUpdated(long lastUpdate) {
		this.lastUpdate = lastUpdate;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}
}